Function LastCell(ws As Worksheet) As Range
Dim LastRow, LastCol
' Error-handling is here in case there is not any
' data in the worksheet
On Error Resume Next
With ws
' Find the last real row
LastRow = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
' Find the last real column
LastCol = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).column
End With
' Finally, initialize a Range object variable for
' the last populated row.
Set LastCell = ws.Cells(LastRow, LastCol)
Cells(LastRow, LastCol).Select
If IsEmpty(LastRow) Then
MsgBox ("No data in worksheet")
End
End If
End Function
'''''''''
Sub RealLastCell()
rlc = LastCell(ActiveSheet).Address(False, False)
lr = ActiveCell.Row
lc = ActiveCell.column
End Sub